<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="srcPath" value="${redis:getSysConfig('sysFileVisitRoot_back')}"/>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<c:set var="htmlPath" value="${redis:getSysConfig('in_path_html')}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>修改密码</title>
<jsp:include page="../../util/import.jsp"/>
<script type="text/javascript">

    /**
     * 自定义验证规则
     */
    function validateForm(){
        form.bootstrapValidator({
            message: "无效的值",
            feedbackIcons: {
                valid: "glyphicon glyphicon-ok",
                invalid: "glyphicon glyphicon-remove",
                validating: "glyphicon glyphicon-refresh"
            },
            fields: {
                oldPassWord: {
                    validators: {
                        notEmpty: {message: "请填写旧密码"},
                        stringLength: {min: 6,max: 20,message: "密码长度为6至20"},
                        regexp: {
                            regexp:validateUtil.onlyCharAndNumber,
                            message: '只能填写字母或者数字'
                        }
                    }
                },
                password: {
                    validators: {
                        notEmpty: {message: "请填写新密码"},
                        stringLength: {min: 6,max: 20,message: "密码长度为6至20"},
                        regexp: {
                            regexp:validateUtil.onlyCharAndNumber,
                            message: '只能填写字母或者数字'
                        }
                    }
                },
                repassword: {
                    validators: {
                        notEmpty: {message: "请填写确认密码"},
                        stringLength: {min: 6,max: 20,message: "密码长度为6至20"},
                        regexp: {
                            regexp:validateUtil.onlyCharAndNumber,
                            message: '只能填写字母或者数字'
                        },
                        identical: {/**相同**/
                            field: 'password',
                            message: '两次密码不一致'
                        }
                    }
                }
            }
        });
    }

    function sForm(){
        /**开启验证**/
        form.data('bootstrapValidator').validate();
        isValid=form.data('bootstrapValidator').isValid();
        if(isValid){ /**验证通过后提交表单**/
            var options = {
                url: form.attr("action"),
                type : "post",
                dataType:"json",
                success : function(data) {
                    if(data.success==true){
                        showMsg("保存成功！");
                    }else{
                        showMsg("保存失败！");
                    }
                }
            };
            form.ajaxSubmit(options);
        }else{ /**验证失败了直接返回**/
            return ;
        }
    }
</script>
</head>
<body>
    <div class="panel-body" id="customer-main-panel">
        <div class="panel panel-default" style="width:60%;margin-left:auto;margin-right:auto;" >
            <div class="panel-heading">修改密码</div>
            <div class="panel-body">
                <form id="form1" class="form-horizontal" action="${basePath}/back/users/updatePassword.sjson">
                    <table align="center" class="addOrEditTable table-bordered table" style="width:100%;margin-top: 20px;">
                        <tr>
                            <td class="toright_td" width="140px"><span style="color:red">* </span>旧密码:&nbsp;&nbsp;</td>
                            <td  class="toleft_td" colspan="3">
                                <div class="form-group" style="padding-left:15px;padding-right:15px;">
                                    <input  type="password" class="form-control input-sm" id="oldPassWord" name="oldPassWord" placeholder="请输入旧密码"/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="toright_td" width="140px"><span style="color:red">* </span>新密码:&nbsp;&nbsp;</td>
                            <td  class="toleft_td" colspan="3">
                                <div class="form-group" style="padding-left:15px;padding-right:15px;">
                                    <input type="password" class="form-control input-sm" id="txtNewPass" name="password" placeholder="请输入新密码"/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="toright_td" width="140px"><span style="color:red">* </span>确认密码:&nbsp;&nbsp;</td>
                            <td  class="toleft_td" colspan="3">
                                <div class="form-group" style="padding-left:15px;padding-right:15px;">
                                    <input type="password" class="form-control input-sm" id="txtRePass" name="repassword"  placeholder="请输入确认密码"/>
                                </div>
                            </td>
                        </tr>
                    </table>
                    <div class="modal-footer" >
                        <button type="button" id="validateBtn" class="btn btn-primary"  onclick="sForm()">修改</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>

